<template>
  <div class="clas_All">
    <el-row>
      <el-col :span="24">
        <div class="grid-content bg-purple-dark">
          <el-form :model="queryParams" size="small" :inline="true">
            <el-form-item prop="">
              <el-date-picker
                v-model="queryParams.date"
                type="date"
                placeholder="选择审核时间"
                @change="createdTimeChange"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item prop="">
              <el-input
                v-model="queryParams.fbillno"
                placeholder="请输入采购单据"
                clearable
                :disabled="Showinpt"
              />
            </el-form-item>
            <el-form-item prop="">
              <el-input
                v-model="queryParams.fmaterialIdfnumber"
                placeholder="请输入物料编号"
                clearable
                :disabled="Showinpt"
                @keyup.enter.native=""
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" size="mini" @click="getProCurList"
                >查询</el-button
              >
            </el-form-item>
          </el-form>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col>
        <el-table :data="menuList">
          <el-table-column
            align="center"
            prop="fbillno"
            label="采购单据"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="fdate"
            label="采购日期"
          ></el-table-column>
          <!-- fapproveDate -->
          <el-table-column
            align="center"
            prop="fapproveDate"
            label="采购日期"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="spec"
            label="规格型号"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="fstockOrgIdfname"
            label="申请组织"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="fstockIdfname"
            label="厨部分组"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="fmaterialIdfnumber"
            label="物料编号"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="fmaterialIdfname"
            label="物料名称"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="fpriceUnitIDfname"
            label="计件单位"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="frealQty"
            label="申请数量"
          ></el-table-column>
        </el-table>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getProCurList"
        />
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { inchangePage } from "@/api/system/cost.js";
export default {
  data() {
    return {
      AllotList: {},
      total: 0,
      Showinpt: true,
      menuList: [],
      queryParams: {
        pageSize: 10,
      },
    };
  },
  created() {
    this.getProCurList();
  },
  methods: {
    getProCurList() {
      console.log(this.queryParams);
      inchangePage(this.queryParams).then((res) => {
        if (res.code == 200) {
          this.menuList = res.rows;
          this.total = res.total;
        }
      });
    },
    createdTimeChange(v) {
      if (v) {
        const originalDate = new Date(v);
        const year = originalDate.getFullYear();
        const month = String(originalDate.getMonth() + 1).padStart(2, "0"); // 月份从0开始，需要加1
        const day = String(originalDate.getDate()).padStart(2, "0");
        // 拼接成目标格式的日期字符串
        this.queryParams.date = `${year}-${month}-${day}`;
        this.Showinpt = false;
      } else {
        this.Showinpt = true;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.clas_All {
  margin: 20px;
}
</style>
